import { ADD_NUMBER, SUB_NUMBER, INC_NUMBER } from './constants.js'

const initialState = { counter: 0 }

export default (state = initialState, action) => {
  switch (action.type) {

    case ADD_NUMBER:
      return { ...state, counter: state.counter + action.num }
    case SUB_NUMBER:
      return { ...state, counter: state.counter - action.num }
    case INC_NUMBER:
      return { ...state, counter: state.counter + 1 }
    default:
      return state
  }
}
